package com.itheima;

import java.util.Calendar;
import java.util.Scanner;

public class DemoEryue {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        int year=sc.nextInt();
        Calendar cl=Calendar.getInstance();
        cl.set(year,2,1);
        cl.add(Calendar.DATE,-1);
        int day=cl.get(Calendar.DATE);
        System.out.println(day);
    }
}
